package com.syncshot.androidapp.utils;

import com.syncshot.androidapp.Constant;
import com.syncshot.androidapp.R;
import com.syncshot.androidapp.activities.HomeActivity;
import com.syncshot.androidapp.activities.TakePictureActivity;
import com.syncshot.androidapp.activities.WaitingRoomActivity;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

public class NotifUtils {
	
	public static void displayNotification(Context ctx, String msg, String title, String eventId, int ttl, String eventOwner){
		
		Intent notifIntent = new Intent(ctx, HomeActivity.class);
		
        PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
		
		NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
		 builder.setContentIntent(contentIntent); //
         //.setDeleteIntent(deleteIntent)
         builder.setSmallIcon(R.drawable.ic_launcher) //
         .setTicker(msg) //
         .setWhen(System.currentTimeMillis()) //
         .setAutoCancel(true) //
         .setContentTitle(title) //
         //.setDefaults(Notification.DEFAULT_ALL)
         .setContentText(msg);
         
         NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
         Notification n = builder.getNotification();
         nm.notify(0, n);
         
         Intent intent = new Intent(ctx, WaitingRoomActivity.class);
         intent.putExtra(Constant.KEY_EVENT_ID, eventId);
         intent.putExtra(Constant.KEY_EVENT_OWNER, eventOwner);
         intent.putExtra(Constant.KEY_EVENT_TTL, ttl);
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         ctx.startActivity(intent);
		
	}

}
